﻿namespace Hidistro.UI.SaleSystem.CodeBehind
{
    using Hidistro.Entities.Orders;
    using Hidistro.Membership.Context;
    using Hidistro.SaleSystem.Shopping;
    using Hidistro.UI.Common.Controls;
    using System;
    using System.Web.UI;
    using Hidistro.Core;
    using Hidistro.Entities.Comments;
    using Hidistro.SaleSystem.Comments;
    using Hidistro.UI.SaleSystem.Tags;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Xml;
    using System.Web;
    using Hidistro.Entities.Commodities;
    using System.Collections.Generic;
    using Juse.Interface;
    [ParseChildren(true)]
    public class Store : HtmlTemplatedWebControl
    {
        private Literal hot;
        private Literal top;
        private YB_Store_CategoryTopProduct categorytopproduct;
        private int categoryid = 0;
        protected void Loadtitle(int categoryid)
        {

            string Title = "成人用品专题_夫妻成人情趣用品_男女两性用品_夫妻性爱保健用品商城";
            string Keywords = "成人用品专题,夫妻成人情趣用品,男女两性用品,夫妻性爱保健用品商城";
            string Description = "橘色成人用品官网销售成人用品,情趣用品性用品夫妻性爱生活用品成人玩具专业平台。橘色商城中所有成人情趣性用品均由正规厂商生产。信誉度最高的成人用品|性用品|情趣用品大型网上商城高档情趣用品,性用品各类成人保健两性生活用品货到付款,保密配送。";
            switch (categoryid)
            {
                case 1:
                    Title = "【男性用品】男性情趣用品_男性性用品_男性自慰器";
                    Keywords = "男性成人用品,男性自慰器,男性用品,男性性用品,情趣用品,手淫用品";
                    Description = "橘色商城（男性用品）为您提供自慰、女优名器、手淫用品、男性用品、男性自慰器、真人玩具等男性全面成人用品，两性成人情趣用品货到付款，保密配送！";
                    break;
                case 5:
                    Title = "【女性自慰器】女用自慰器具_女性性玩具_女性成人用品_女性性用具";
                    Keywords = "女性成人用品,自慰器,性用品,女性自慰器,情趣用品 女性高潮";
                    Description = "橘色商城为您提女人性用品 女性自慰器 多点刺激棒、仿真玩具、女性高潮、等女性全面成人用品，两性成人情趣用品专营进口女性性用品正品保障，货到付款，保密配送！";
                    break;
                case 17:
                    Title = "【延时助情】夫妻调情用品_调情用品_夫妻保健品_房事保健品";
                    Keywords = "调情用品,夫妻用品,夫妻保健,夫妻保健品,房事保健品,夫妻调情用品";
                    Description = "橘色商城(延时助情)专卖夫妻性生活调情用品,延时喷剂,润滑油、润滑液等夫妻房事性趣保健品。全国货到付款,保密配送,正品保障!";
                    break;

            }
            PageTitle.AddSiteNameTitle(Title);
            MetaTags.AddMetaKeywords(Keywords, Hidistro.Membership.Context.HiContext.Current.Context);
            MetaTags.AddMetaDescription(Description, Hidistro.Membership.Context.HiContext.Current.Context);
        }

        protected override void AttachChildControls()
        {
            hot = (Literal)this.FindControl("hot");
            top = (Literal)this.FindControl("top");
            categorytopproduct = (YB_Store_CategoryTopProduct)this.FindControl("categorytopproduct");
            int.TryParse(this.Page.Request.QueryString["Categoryid"], out categoryid);

            XmlDocument xml = new XmlDocument();
            xml.Load(HttpContext.Current.Request.MapPath(HiContext.Current.GetSkinPath() + "/config/YB_Store.xml"));
            XmlNode node = xml.SelectSingleNode(string.Format("//Store[@cid='{0}']", categoryid));
            hot.Text = node["StoreHot"].InnerXml;
            top.Text = node["StoreTop"].InnerXml;

            XmlNodeList xlist = node["Categorylist"].SelectNodes("category");
            List<CategoryInfo> clist = new List<CategoryInfo>();
            // <h4><a target="_blank" href="<%# Globals.GetSiteUrls().SubCategory((int)Eval("CategoryId"), Eval("RewriteName")) %>"><%#Eval("Name")%></a></h4>
            System.Collections.Generic.List<JSShop.Model.Hishop_Categories> clist2 = new CategoryBrowser().GetSubCategories(0, 0);
            if (xlist != null)
            {
                foreach (XmlNode x in xlist)
                {
                    CategoryInfo cinfo = new CategoryInfo();
                    cinfo.CategoryId = int.Parse(x.Attributes["id"].Value);
                    cinfo.Name = x.Attributes["name"].Value;
                    cinfo.CalssName = x.Attributes["Cname"].Value;
                    foreach (var v in clist2)
                    {
                        if (cinfo.CategoryId == v.CategoryId)
                        {
                            cinfo.RewriteName = v.RewriteName;
                        }
                    }
                    
                    clist.Add(cinfo);
                }
            }
            this.categorytopproduct.DataSource = clist;
            this.categorytopproduct.DataBind();

            Loadtitle(this.categoryid);
        }

        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "Skin-Store.html";
            }
            base.OnInit(e);
        }
    }
}

